package com.example.sort;

/**
 * Created by Quincy on 2018/9/12.
 */
public class HeapSort1 {

    private HeapSort1(){}

    public static void sort(Comparable[] arr){
        int n = arr.length;
        MaxHeap<Comparable> maxHeap = new MaxHeap<Comparable>(n);
        for (int i = 0; i < n; i++)
            maxHeap.insert(arr[i]);
        for (int i = n-1; i >= 0; i--)
            arr[i] = maxHeap.extractMax();
    }
}
